How to remove caracters like (), ' * [] form a grep results with grep, awk or sed?
Posted
by
easyyu
on Stack Overflow
See other posts from Stack Overflow
or by easyyu
Published on 2011-01-17T03:25:04Z
Indexed on
2011/01/17
3:53 UTC
Read the original article
Hit count: 228
For example if I made a file with grep that give me a next result:
16 Jan 07:18:42 (name1), xx.210.49.xx),
16 Jan 07:19:14 (name2), xx.210.xx.24),
16 Jan 07:19:17 (name3), xx.140.xxx.79),
16 Jan 07:19:44 (name4), xx.210.49.xx),
16 Jan 07:19:56 (name5), xx.140.xxx.79),
,then how to sed awk or grep to remove all except date name and IP to look like this:
16 Jan 07:18:42 name1 xx.210.49.xx
16 Jan 07:19:14 name2 xx.210.xx.24
16 Jan 07:19:17 name3 xx.140.xxx.79
16 Jan 07:19:44 name4 xx.210.49.xx
16 Jan 07:19:56 name5 xx.140.xxx.79
My grep command look like this:
grep 'double' $DAEMON | awk -F" " '{print $2" "$1" "$3" "$8" "$10}' > $DBLOG
Thx.
© Stack Overflow or respective owner